/********************************************************************************************************************************
 * 《C ++ Primer》第五版中文版，读书笔记：按照书中的的示例源码和每一个小章节的课后习题，自己动手写代码实现，作为联系和测试。
 * Date: 2024-03-19 11:56
 * Author: dimon.chen 
 * EMali: 1181302388@qq.com 
 * 
 * 章节: 1.4.1 控制流 while 的使用
 *       1.4.1 节练习：
 *       1.9 编写程序，使用while循环将50到100的整数相加
 *       1.10 使用c--运算符
 *       1.11 提示用户输入两个数字，并输出两个数字之间的整数  
 * 
 ********************************************************************************************************************************/

#include <iostream>

int main(int argc, char *argv[]){
    int sum = 0;
    int val = 50;

    while(val < 100){
        sum += val;
        val++;
    }

    std::cout << "the sum of number between 50 and 100 is: " << sum << std::endl;

    ///
    ///Examine 1.10 
    std::cout << "Examine 1.10" << std::endl;
    std::cout << "the number decrease from 10 to 0 :" << std::endl;
    val = 10;
    while(val >= 0){
        std::cout << val << std::endl;
        val--;
    }
    //std::cout << std::endl;

    ///Examine 1.11
    std::cout << "Examine 1.11" << std::endl;
    std::cout << "Please enter two number" << std::endl;
    int v1 =0;
    int v2 = 0;
    std::cin >> v1 >> v2;

    ///print the number between v1 and v2
    std::cout << "the number between " << v1 << " and " << v2 << " is :" << std::endl;
    if(v1 > v2){
        while(v2+1 < v1){
            v2++;
            std::cout << v2 << " ";
        }
    }
    else if (v2 > v1){
        while(v1+1 < v2){
            v1++;
            std::cout << v1 << " ";
        }
    }
    else {
        std::cout << "v1 is equal v2, no number between v1 and v2";
    }

    std::cout << std::endl;

    return 0;
}